/* 

手写实现字符串转整数
string -> number

*/

let solution = function (string) {
    let res = [];
    let nums = string.split("");

    for (let num of nums) {
        if ((num.charCodeAt() - "0".charCodeAt() >= 0) && ("9".charCodeAt() - num.charCodeAt() >= 0)) {
            res.push(num - 0)
        }
    }

    return Math.floor(res.join(""));
}

let testString = "132abc80"
console.log(solution(testString))
// console.log("9".charCodeAt() - "0".charCodeAt())
// console.log("9".charCodeAt())